package com.irilya.youtubeevents.gwt.client;

import com.irilya.youtubeevents.gwt.client.model.YouTubeEvent;
import com.irilya.youtubeevents.gwt.client.model.YouTubePlayer;
import com.irilya.youtubeevents.gwt.client.service.YouTubeEventService;
import com.irilya.youtubeevents.gwt.client.service.YouTubePlayerService;
import com.irilya.youtubeevents.gwt.client.service.ServiceProvider;

import java.util.HashMap;
import java.util.Map;


public class YouTubeEventHandler {

    private Map<String, YouTubeEvent> events;

    private YouTubeEventsContext youTubeEventsContext;

    public YouTubeEventHandler(YouTubeEventsContext youTubeEventsContext) {

        this.youTubeEventsContext = youTubeEventsContext;
        this.events = new HashMap<String, YouTubeEvent>();
    }

    public static void onYouTubePlayerReady(String playerId) {
        System.out.println(playerId);
    }

    public static void broadCastEvents() {


    }

    public void addEvent(YouTubeEvent event) {
        events.put(event.getId(), event);
    }

    public void removeEvent(YouTubeEvent event) {
        events.remove(event);
    }

    public Map<String, YouTubeEvent> getEvents() {
        return events;
    }

    private YouTubeEventService getYouTubeEventService() {
        return (YouTubeEventService) ServiceProvider.getInstance().getService("eventService");
    }

    private YouTubePlayerService getYouTubePlayerService() {
        return (YouTubePlayerService) ServiceProvider.getInstance().getService("playerService");
    }    
}
